package org.sca.middle.cmpe.dto;

import java.io.Serializable;

/**
 * <p>Updated 3/6/2014: Fixed The serializable class AuthType does not declare a static final serialVersionUID field of type long</p>
 * <p>Updated: Added properties category and martial.</p>
 * @author rik
 * @author Kevin Carlen
 * @version 1.2
 */
public class AuthType implements Serializable, Comparable<AuthType> {

	/**
	 * UID for {@link java.io.Serializable}
	 */
	private static final long serialVersionUID = 5598701479727504412L;

	/** Key value */
	private Long authTypeId;
	
	/** authorization code */
    private String code;
    
    /** authorization description */
    private String description;
    
    /** authorization category */
    private AuthCategory category;
    
    /** Is a marshal authorization */
    private boolean martial;
    
    /** the sort order */
    private Long orderValue;

    /**
     * @return
     */
    public Long getAuthTypeId() {
        return authTypeId;
    }

    /**
     * @param authTypeId
     */
    public void setAuthTypeId(Long authTypeId) {
        this.authTypeId = authTypeId;
    }

    /**
     * @return
     */
    public String getCode() {
        return code;
    }

    /**
     * @param code
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @return
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
	 * @return the category
	 */
	public AuthCategory getCategory() {
		return category;
	}

	/**
	 * @param category the category to set
	 */
	public void setCategory(AuthCategory category) {
		this.category = category;
	}

	/**
	 * @return the martial
	 */
	public boolean isMartial() {
		return martial;
	}

	/**
	 * @param martial the martial to set
	 */
	public void setMartial(boolean martial) {
		this.martial = martial;
	}

	/**
	 * @return
	 */
	public Long getOrderValue() {
        return orderValue;
    }

    /**
     * @param orderValue
     */
    public void setOrderValue(Long orderValue) {
        this.orderValue = orderValue;
    }

	/**
	 * Determines comparison based on orderValue. If orderValue is the same then base comparison on code.
	 * @param arg0 the other {@link AuthType} to compare to
	 * @return the difference in orderValue
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	@Override
	public int compareTo(AuthType arg0) {
		if (arg0.getOrderValue().intValue() == getOrderValue().intValue()) {
			return getCode().compareTo(arg0.getCode());
		}
		return arg0.getOrderValue().intValue() - getOrderValue().intValue();
	}
}
